From a9814fea7d169400b033bc28f3b7570b3423bc15 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 6 Nov 2015 18:57:24 +0100 Subject: [PATCH] stylecontext: Always warn on style mismatch For now, always warn when gtk_style_context_get()/get_padding()/get_margin()/get_border() get called with the wrong state. We used to hide this behind an env var because the warnings were too frequent, but with the recent refactorings, this warning has become rather important for detecting bugs. If it's still problematic, we might want to revert this patch before 3.20. --- gtk/gtkstylecontext.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index e5fa5f2fa5..46be12c0f9 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -490,27 +490,25 @@ gtk_style_context_push_state (GtkStyleContext *context, { GtkStyleContextPrivate *priv = context->priv; GtkStateFlags current_state; + GtkCssNode *root; current_state = gtk_css_node_get_state (priv->cssnode); if (current_state == state) return state; - if (g_getenv ("GTK_STYLE_CONTEXT_WARNING")) - { - GtkCssNode *root = gtk_style_context_get_root (context); + root = gtk_style_context_get_root (context); - if (GTK_IS_CSS_WIDGET_NODE (root)) - { - GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (root)); - g_warning ("State %u for %s %p doesn't match state %u set via gtk_style_context_set_state ()", - state, gtk_widget_get_name (widget), widget, gtk_css_node_get_state (priv->cssnode)); - } - else - { - g_warning ("State %u for context %p doesn't match state %u set via gtk_style_context_set_state ()", - state, context, gtk_css_node_get_state (priv->cssnode)); - } + if (GTK_IS_CSS_WIDGET_NODE (root)) + { + GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (root)); + g_warning ("State %u for %s %p doesn't match state %u set via gtk_style_context_set_state ()", + state, gtk_widget_get_name (widget), widget, gtk_css_node_get_state (priv->cssnode)); + } + else + { + g_warning ("State %u for context %p doesn't match state %u set via gtk_style_context_set_state ()", + state, context, gtk_css_node_get_state (priv->cssnode)); } gtk_css_node_set_state (priv->cssnode, state); -- 2.30.2